package com.azring.azring

import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine

/**
 * 主活动类
 * 负责初始化 Flutter 引擎和戒指数据通信通道
 */
class MainActivity: FlutterActivity() {
    
    private var ringDataChannel: RingDataChannel? = null

    override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
        super.configureFlutterEngine(flutterEngine)
        
        // 初始化戒指数据通信通道
        ringDataChannel = RingDataChannel(this, flutterEngine)
    }

    override fun onRequestPermissionsResult(
        requestCode: Int,
        permissions: Array<String>,
        grantResults: IntArray
    ) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults)
        // 权限请求结果处理
        if (requestCode == 1001) { // BLUETOOTH_PERMISSION_REQUEST_CODE
            // 可以在这里处理蓝牙权限请求结果
        }
    }

    override fun onDestroy() {
        super.onDestroy()
        // 清理资源
        ringDataChannel?.dispose()
    }
}
